home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / mis_cnvt / dbtfpt / dbt2fpt.prg < prev    next >
Text File  |  1993-03-29  |  2KB  |  88 lines

  1. /*
  2.    DBT2FPT.PRG - Memo file converter by Loren Scott / SuccessWare 90, Inc.
  3.  
  4.    This is a simple program demonstrating how to convert Clipper .DBT's
  5.    to FoxPro-compatible FPT's using the Clipper 5.2 DBFCDX RDD.
  6.  
  7.     Compile:  CLIPPER dbt2fpt /n/w
  8.     Link   :  BLINKER FI dbt2fpt LIB dbfcdx,clipper
  9.  
  10.    ---------------------------------------------------------------------
  11. */
  12.  
  13. #include "RDDSYS.CH"
  14.  
  15. REQUEST DBFCDX
  16.  
  17.  
  18. FUNC DBT2FPT( cOldFile, cNewFile )
  19.  
  20. LOCAL aFile := {}
  21.  
  22. cOldFile := Upper( AllTrim( cOldFile ))
  23. cNewFile := Upper( AllTrim( cNewFile ))
  24.  
  25. IF "." $ cOldFile
  26.   cOldFile := Left( cOldFile, at( ".", cOldFile )-1 )
  27. ENDIF
  28.  
  29. IF "." $ cNewFile
  30.   cNewFile := Left( cNewFile, at( ".", cNewFile )-1 )
  31. ENDIF
  32.  
  33. // Display a message
  34. ? "DBT2FPT - Memo File Converter"
  35. ?
  36.  
  37. // Make sure we got the correct parameters
  38. IF PCOUNT() < 2
  39.   ? "USAGE:  DBT2FPT <oldfile> <newfile>"
  40.   ?
  41.   ? "where:  <oldfile> = Name of the database containing the memo"
  42.   ? "                    field to convert."
  43.   ? "        <newfile> = New file to create"
  44.   ?
  45.   Return(1)
  46. ENDIF
  47.  
  48. // Check for the original file
  49. IF !File( cOldFile + ".DBF" )
  50.   ? "Cannot find " + cOldFile + "!"
  51.   ?
  52.   Return(2)
  53. ENDIF
  54.  
  55. // Open the original file (using DBFNTX)
  56. USE (cOldFile) VIA "DBFNTX"
  57.  
  58. // Set DBFCDX Driver as the default for creating new dbf
  59. RDDSetDefault("DBFCDX")
  60.  
  61. // Show that we're doing something
  62. ? "Working"
  63.  
  64. // Now copy to the new file (with nifty UDF)
  65. COPY TO (cNewFile) FOR ShowDot()
  66.  
  67. // Look, we made it!
  68. ?? "Done!"
  69. ?
  70.  
  71. // Clean up before leaving
  72. CLOSE ALL
  73.  
  74. // Compare file sizes
  75. aFile := Directory( cOldFile + ".DBT" )
  76. ? PadR( "Old " + cOldFile + ".DBT Size",21 ) + ": "
  77. ?? Str( aFile[1,2] ) + " bytes"
  78. aFile := Directory( cNewFile + ".FPT" )
  79. ? PadR( "New " + cNewFile + ".FPT Size",21 ) + ": "
  80. ?? Str( aFile[1,2] ) + " bytes"
  81. ?
  82.  
  83. Return(0)
  84.  
  85. FUNC ShowDot()
  86.   ?? "."
  87. Return (.T.)
  88.